<template>
	<view>
		<view v-if="data"
			style="display: flex;justify-content: space-between;padding-top: 10rpx;padding: 10rpx;border-radius: 10px;">
			<view style="display: flex;width: 100%;">
				<view>
					<image
						:src="(data!=null&&data.images!=null&&data.images.split(',').length>0)?data.images.split(',')[0]:'/static/images/未上传门店照片.png'"
						style="width: 140rpx;height: 140rpx;border-radius: 8px;" @click="previewImage()">
					</image>
				</view>
				<view class="margin-left-xs" style="width: 100%;">
					<view class=" flex justify-between text-gray">
						<view style="font-size: 32rpx;font-weight: bold;color: #636161;">
							{{data.orgName||"加载中"}}
						</view>
						<view style="display: flex;" @click="Navigation">
							<image src="@/static/images/导航(2).png" style="width:43rpx;height: 43rpx;"></image>
							<image src="@/static/images/拨号(2).png" style="width:40rpx;height: 40rpx;"
								class="margin-left-xs">
							</image>
						</view>
					</view>

					<view class="margin-top-xs flex justify-between text-gray" style="font-size: 24rpx;">
						<text>
							{{data.address||"商家未设置位置信息"}}
						</text>

						<text
							class=" text-black text-bold  ">{{data.distance==null?"无位置":data.distance>1000?((data.distance/1000).toFixed(1)+"Km"):data.distance+"m"}}</text>

					</view>
					<view class="margin-top-xs text-gray font-12">

						<!-- 			<text :class="{'mendianTap':true,'bg-green-fan':data.isidle==0,'bg-red':data.isidle>0}  "
							style="border-width: 0px;padding: 3rpx 10rpx;">{{data.isidle>0?'紧张':'空闲'}}</text> -->
						<text v-if="data.tag!=null" class="mendianTap"
							v-for="item in data.tag.split(',')">{{item}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "storeItem",
		props: {
			data: {
				type: Object,
				default: function() {},
			}
		},
		onShow() {
			this.init()
		},
		data() {
			return {
				location: {}
			};
		},
		methods: {

			Navigation() {
				uni.navigateTo({
					url: "/pages/common/MapNavigation/MapNavigation?id=" + this.data.id
				})
			},
			init() {
				this.location = storage.get("location")
				console.log(this.location.distance);
			},
			/**
			 * 预览图片
			 */
			previewImage() {

				let imgList = (this.data != null && this.data.image != null && this.data.image.split(',').length > 0) ?
					this.data.image.split(
						',') : []
				uni.previewImage({
					current: imgList[0], // 当前显示的图片链接
					urls: imgList, // 需要预览的图片链接列表
					indicator: 'number'
				});
				// this.$emit("showImg", imgList)
			},
			// call() {

			// 	uni.navigateTo({
			// 		url: "/pages/common/MapNavigation/MapNavigation?id=" + this.data.id
			// 	})
			// 	return
			// 	if (this.data.phone == null) {
			// 		uni.showModal({
			// 			title: "提示",
			// 			content: "商家未正确配置联系方式,请从其他渠道联系商家",
			// 			showCancel: false
			// 		})
			// 		return
			// 	}
			// 	uni.makePhoneCall({
			// 		phoneNumber: this.data.phone,
			// 		success: function() {
			// 			console.log('拨打电话成功');
			// 		},
			// 		fail: function(error) {
			// 			console.log('拨打电话失败', error);
			// 		}
			// 	});

			// }

		}
	}
</script>

<style>
	.mendianTap {
		margin-top: 5rpx;
		padding: 1px 4px;
		border: solid #999 1px;
		margin-right: 10rpx;
		margin-top: 5rpx;
		border-radius: 5px;
		margin-bottom: 5rpx;
	}
</style>